// Ts中如果从.d.ts类型文件中导入类型，前面要加type
import type {
  IGetCodeData,
  ILoginCodeParams,
  LoginCodeData,
  LoginCodeParams,
  LoginDataType,
  LoginParams,
  UserData,
} from '@/type/user'
import request from '@/utils/request'

export const LoginAPI = (data: LoginParams) => {
  return request.post<null, LoginDataType>('/login/password', data)
}

// 获取验证码的API
export const getCodeAPI = (params: ILoginCodeParams) => {
  return request.get<null, IGetCodeData>('/code', { params })
}

// 验证码登录的API
export const loginByCodeAPI = (data: LoginCodeParams) => {
  return request.post<null, LoginCodeData>('/login', data)
}

// 查询用户个人信息
export const getUserInfoAPI = () => {
  return request.get<null, UserData>('/patient/myUser')
}
